package cn.i7baozh.starter.client.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.slf4j.MDC;

/**
 * 通过open feign调用时添加日志追踪
 *
 * @author : baoqi.zhang
 * @date :   2022/5/11 14:41
 */
public class OpenFeignLoggingInterceptor implements RequestInterceptor {

    private static final String DISTRIBUTE_LOGGING_FLAG = "_traceId_";

    @Override
    public void apply(RequestTemplate template) {
        template.header(DISTRIBUTE_LOGGING_FLAG, MDC.get(DISTRIBUTE_LOGGING_FLAG));
    }
}
